package validate

import (
	"github.com/Gre-Z/common/jtime"
	teamones_helper "github.com/teamones-open/go-helper"
	"gorm.io/datatypes"
)

type AddLogs struct {
	Data []AddLog `json:"data" binding:"required"`
}

type AddLog struct {
	Id           int64            `json:"id"`
	Level        string           `json:"level" binding:"required,oneof=info warn error"`
	Operate      string           `json:"operate" binding:"required,oneof=query create update delete"`
	Record       datatypes.JSON   `json:"record" binding:"required"`
	ModuleCode   string           `json:"module_code" binding:"required,max=36"`
	LinkId       int64            `json:"link_id" binding:"required,gt=0"`
	CreatedBy    string           `json:"created_by" binding:"required,max=36"`
	BatchNumber  string           `json:"batch_number" binding:"required,max=255"`
	BelongSystem string           `json:"belong_system" binding:"required,max=128"`
	Created      jtime.TstampTime `json:"created"`
	Uuid         string           `json:"uuid"`
}

type SelectLogQuery struct {
	Param teamones_helper.QueryParam `json:"param" binding:"required"`
}

type AddTransactionRecords struct {
	Id             int64   `json:"id"`
	Type           string  `json:"type" binding:"required,oneof=recharge order"`
	EntryDirection int     `json:"entry_direction"`
	Amount         float64 `json:"amount" binding:"required"`
	LinkId         int64   `json:"link_id" binding:"required,gt=0"`
	CreatedBy      string  `json:"created_by" binding:"required,max=36"`
	BelongSystem   string  `json:"belong_system" binding:"required,max=128"`
}

type AddMonolog struct {
	Id           int64            `json:"id"`
	Level        string           `json:"level" binding:"required"`
	Route        string           `json:"route" binding:"max=255"`
	RequestParam datatypes.JSON   `json:"request_param" binding:"required"`
	Record       string           `json:"record" binding:"max=16777215"`
	BelongSystem string           `json:"belong_system" binding:"required,max=128"`
	Created      jtime.TstampTime `json:"created"`
}

type SelectMonolog struct {
	Param teamones_helper.QueryParam `json:"param" binding:"required"`
}

type RequestLog struct {
	Request   Request        `json:"request"`
	ClientIP  string         `json:"client_ip"`
	Upstream  string         `json:"upstream"`
	RouteID   string         `json:"route_id"`
	StartTime int64          `json:"start_time"`
	Response  datatypes.JSON `json:"response"`
	ServiceID string         `json:"service_id"`
	Latency   float64        `json:"latency"`
	Server    datatypes.JSON `json:"server"`
}
type Request struct {
	Querystring datatypes.JSON `json:"querystring"`
	Method      string         `json:"method"`
	Body        string         `json:"body"`
	Size        int            `json:"size"`
	URL         string         `json:"url"`
	URI         string         `json:"uri"`
	Headers     datatypes.JSON `json:"headers"`
}
